//1.双指针(快慢指针)-快乐数(链表判环问题)
class Solution {
public: 
    int calc(int n)
    {
        int sum = 0;
        while(n)
        {
            sum += (n % 10) * (n % 10);
            n /= 10;
        }
        return sum;
    }

    bool isHappy(int n) {
        int fast = calc(n), slow = n;
        while(fast != slow)
        {
            fast = calc(calc(fast));
            slow = calc(slow);
        }
        return fast == 1;
    }
};

//2.双指针-盛水最多的容器(单调性)
class Solution {
public:
    int maxArea(vector<int>& height) {
        int l = 0, r = height.size() - 1;
        int ret = 0;
        while(l < r)
        {
            ret = max(ret, min(height[l], height[r]) * (r - l));
            if(height[l] > height[r]) r--;
            else l++;
        }
        return ret;
    }
};
